﻿using System;
using System.Data;
using System.Text;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using AnyOffice.Components;
using AnyOffice.DAL;
using AnyOffice.Model;
using log4net;
using System.Reflection;
namespace AnyOffice.general.sms
{
    public partial class _new : ModulePage
    {
        private static ILog log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
       
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!this.Page.IsPostBack)
            {
                string str = (Request.QueryString["to_id"] != null) ? Request.QueryString["to_id"].ToString() : "";
                string str2 = (Request.QueryString["to_name"] != null) ? Request.QueryString["to_name"].ToString() : "";
                if (Request.QueryString["sms_id"] != null)
                {
                    int smsId = int.Parse(Request.QueryString["sms_id"].ToString());
                    new SmsDao().CancelRemind(base.Conn, smsId, base.User.Identity.Name);
                }
                if (str != string.Empty)
                {
                    this.ToId.Value = str + ",";
                }
                if (str2 != string.Empty)
                {
                    this.ToName.Value = str2 + ",";
                }
            }
            if (this.Page.IsPostBack)
            {
                this.pnlMain.Visible = false;
                this.pnlLater.Visible = true;
                SmsData data = new SmsData();
                SmsDao dao = new SmsDao();
                data.FromId = base.User.Identity.Name;
                data.Type = 0;
                data.Content = this.txtContent.Value;
                if (this.ToId.Value == "ALL_DEPT")
                {
                    data.ToDeptList = "ALL_DEPT";
                }
                else
                {
                    data.ToIdList = this.ToId.Value;
                }
                try
                {
                    dao.BizSend(base.Conn, data, true, false);
                }
                catch (Exception exception)
                {
                    if (log.IsErrorEnabled)
                    {
                        log.Error("", exception);
                    }
                }
                this.litMessage.Text = base.ShowPromptNoNav("短信息已发送");
            }
        }

    }
}
